package com.applink.sell_proof.fragment;

import java.util.List;

import android.widget.ListView;

import com.applink.sell_proof.BaseClaim;
import com.applink.sell_proof.builder.ProofBuilderExt;
import com.applink.sell_proof.model.Product;

public class InvoiceDetailExt extends InvoiceDetail {

	public static final String TAG = "InvoiceDetailExt";

	private static boolean mIsDraft = false;

	public static final InvoiceDetailExt newInstance(boolean isDraft) {
		InvoiceDetailExt f = new InvoiceDetailExt();
		mIsDraft = isDraft;
		return f;
	}

	protected void initProductBuilder(ListView l) {

		if (productBuilder != null)
			return;

		productBuilder = new ProofBuilderExt(getActivity(), l);

		List<Product> products = ((BaseClaim) getActivity()).getProducts();

		productBuilder.setData(products);
		if (!mIsDraft) {
			((ProofBuilderExt) productBuilder).setNoedit(true);
		}
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Product> getProducts() {

		List<Product> p = (List<Product>) productBuilder.getData();

		p.addAll(((ProofBuilderExt) productBuilder).getRemovedProductList());

		return p;
	}
}
